import { createSlice } from "@reduxjs/toolkit";

const initialState = {
  start: "上海",
  end: "北京",
  date: "2025-01-01",
  isSpeed: false,
  isSeat: true,
  isDesc: true,
};

export const counterSlice = createSlice({
  name: "counterSlice",
  initialState,
  reducers: {
    setCitySelect(state, { payload }) {
      state[payload.type] = payload.val;
    },
    updateCitySelect(state) {
      const cache = state.start;
      state.start = state.end;
      state.end = cache;
    },
  },
});

export const { setCitySelect, updateCitySelect } = counterSlice.actions;

export default counterSlice.reducer;
